Atmospheric variability

The ERA5 reanalysis dataset provides information about the atmosphere that can help contextualize sea ice conditions. Here, we’ll plot 2 meter temperature and downwelling longwave radiation from ERA5 to get a sense for the atmospheric conditions during each winter season.

import xarray as xr # For working with gridded climate data 
from utils.read_data_utils import read_book_data # Helper function for reading the data from the bucket
from utils.plotting_utils import static_winter_comparison_lineplot, staticArcticMaps, interactiveArcticMaps, compute_gridcell_winter_means # Plotting utils 

# Plotting dependencies
%config InlineBackend.figure_format = 'retina'
import matplotlib as mpl
mpl.rcParams['figure.dpi'] = 150 # Sets figure size in the notebook

# Remove warnings to improve display
import warnings 
warnings.filterwarnings('ignore') 

Read in the data

book_ds = read_book_data() # Read/download the data 
book_ds = book_ds.where(book_ds.region_mask.isin([1,2,3,4,5,6])) # Restrict to the inner arctic 
years = [2018,2019,2020] # Years over which to perform analysis
save_label='Inner_Arctic_MYI'

# Uncomment out to set an additional ice type mask too and change the save_label accordingly (0 = FYI, 1 = MYI)
book_ds = book_ds.where(book_ds.ice_type==1)
Downloading jupyter book data from the google storage bucket...
If you experience problems with multiprocessing on MacOS, they might be related to https://bugs.python.org/issue33725. You can disable multiprocessing by editing your .boto config or by adding the following flag to your command: `-o "GSUtil:parallel_process_count=1"`. Note that multithreading is still available even if you disable multiprocessing.

Copying gs://sea-ice-thickness-data/icesat2-book-data/icesat2-book-data.nc...
/ [0/1 files][    0.0 B/329.4 MiB]   0% Done                                    
-
- [0/1 files][  8.0 MiB/329.4 MiB]   2% Done                                    
\
|
| [0/1 files][ 44.3 MiB/329.4 MiB]  13% Done                                    
/
/ [0/1 files][ 83.5 MiB/329.4 MiB]  25% Done                                    
-
\
\ [0/1 files][126.6 MiB/329.4 MiB]  38% Done                                    
|
/
/ [0/1 files][167.8 MiB/329.4 MiB]  50% Done                                    
-
- [0/1 files][210.1 MiB/329.4 MiB]  63% Done                                    
\
|
| [0/1 files][251.6 MiB/329.4 MiB]  76% Done                                    
/
/ [0/1 files][288.5 MiB/329.4 MiB]  87% Done                                    
-
\
\ [0/1 files][323.0 MiB/329.4 MiB]  98% Done                                    
\ [1/1 files][329.4 MiB/329.4 MiB] 100% Done                                    
Operation completed over 1 objects/329.4 MiB.                                    
Download complete

Map monthly data

Here, we’ll use the interactiveArcticMaps function to display the data. You can change the variable to display by changing data_var in the code cell below if you run the notebook in Binder.

data_var = "t2m"
interactiveArcticMaps(book_ds[data_var], cmap="coolwarm", frame_width=500)

Map and plot the winter means

Below, we’ll compute gridcell means for each month for each variable. Then, we’ll plot the means on a map of the Arctic, and display them next to each other for easy visual comparison.

# Maps of the means 
t2m_winter_means = compute_gridcell_winter_means(book_ds.t2m, years=years)
pl = staticArcticMaps(t2m_winter_means, title="Winter mean 2 meter tempertaure", cmap="coolwarm", vmin=-40, vmax=-15)
display(pl)

# Mean monthly lineplot
static_winter_comparison_lineplot(book_ds.t2m, years=years,  figsize=(5,3), save_label=save_label, legend=True)
---------------------------------------------------------------------------
FileNotFoundError                         Traceback (most recent call last)
/var/folders/2x/8476fbt56qd5m2b5vgkbz2qm0000gp/T/ipykernel_46083/255254877.py in <module>
      1 # Maps of the means
      2 t2m_winter_means = compute_gridcell_winter_means(book_ds.t2m, years=years)
----> 3 pl = staticArcticMaps(t2m_winter_means, title="Winter mean 2 meter tempertaure", cmap="coolwarm", vmin=-40, vmax=-15)
      4 display(pl)
      5 

~/GitHub/akpetty/icesat2-book/content/utils/plotting_utils.py in staticArcticMaps(da, title, out_str, cmap, col, col_wrap, vmin, vmax, set_cbarlabel, min_lat, savefig)
    169     # save figure
    170     if savefig:
--> 171         plt.savefig('./figs/maps_'+out_str+'.png', dpi=400, facecolor="white", bbox_inches='tight')
    172 
    173     plt.close() # Close so it doesnt automatically display in notebook

~/opt/anaconda3/envs/icesat2_book/lib/python3.8/site-packages/matplotlib/pyplot.py in savefig(*args, **kwargs)
    964 def savefig(*args, **kwargs):
    965     fig = gcf()
--> 966     res = fig.savefig(*args, **kwargs)
    967     fig.canvas.draw_idle()   # need this if 'transparent=True' to reset colors
    968     return res

~/opt/anaconda3/envs/icesat2_book/lib/python3.8/site-packages/matplotlib/figure.py in savefig(self, fname, transparent, **kwargs)
   3013                 patch.set_edgecolor('none')
   3014 
-> 3015         self.canvas.print_figure(fname, **kwargs)
   3016 
   3017         if transparent:

~/opt/anaconda3/envs/icesat2_book/lib/python3.8/site-packages/matplotlib/backend_bases.py in print_figure(self, filename, dpi, facecolor, edgecolor, orientation, format, bbox_inches, pad_inches, bbox_extra_artists, backend, **kwargs)
   2253                 # force the figure dpi to 72), so we need to set it again here.
   2254                 with cbook._setattr_cm(self.figure, dpi=dpi):
-> 2255                     result = print_method(
   2256                         filename,
   2257                         facecolor=facecolor,

~/opt/anaconda3/envs/icesat2_book/lib/python3.8/site-packages/matplotlib/backend_bases.py in wrapper(*args, **kwargs)
   1667             kwargs.pop(arg)
   1668 
-> 1669         return func(*args, **kwargs)
   1670 
   1671     return wrapper

~/opt/anaconda3/envs/icesat2_book/lib/python3.8/site-packages/matplotlib/backends/backend_agg.py in print_png(self, filename_or_obj, metadata, pil_kwargs, *args)
    507         """
    508         FigureCanvasAgg.draw(self)
--> 509         mpl.image.imsave(
    510             filename_or_obj, self.buffer_rgba(), format="png", origin="upper",
    511             dpi=self.figure.dpi, metadata=metadata, pil_kwargs=pil_kwargs)

~/opt/anaconda3/envs/icesat2_book/lib/python3.8/site-packages/matplotlib/image.py in imsave(fname, arr, vmin, vmax, cmap, format, origin, dpi, metadata, pil_kwargs)
   1614         pil_kwargs.setdefault("format", format)
   1615         pil_kwargs.setdefault("dpi", (dpi, dpi))
-> 1616         image.save(fname, **pil_kwargs)
   1617 
   1618 

~/opt/anaconda3/envs/icesat2_book/lib/python3.8/site-packages/PIL/Image.py in save(self, fp, format, **params)
   2230                 fp = builtins.open(filename, "r+b")
   2231             else:
-> 2232                 fp = builtins.open(filename, "w+b")
   2233 
   2234         try:

FileNotFoundError: [Errno 2] No such file or directory: './figs/maps_out.png'
../_images/atmospheric_variables_7_1.png
# Maps of the means 
msdwlwrf_winter_means = compute_gridcell_winter_means(book_ds.msdwlwrf, years=years)
pl = staticArcticMaps(msdwlwrf_winter_means, cmap="pink_r", vmin=160, vmax=240)
display(pl)

# Mean monthly lineplot
static_winter_comparison_lineplot(book_ds.msdwlwrf, years=years, figsize=(5,3), set_ylabel=r'Downward longwave radiative flux (W/m$^2$)', save_label=save_label, legend=True)
../_images/atmospheric_variables_8_0.png ../_images/atmospheric_variables_8_1.png